<template>
	<view class="page">
		<view class="bodys">
			<view class="bodys_tit justify-content-sp">
				<view class="bodys_tit_cont " v-for="(item,index) in list" :key="item.id"
					:class="item.id == 0?'red':item.id == 1?'blue':'ora'" @click="toPath(item.id)">
					<view class="">
						向{{item.text}}用户
					</view>
					<view class="">
						转账
					</view>
					<view class="">
						{{item.text2}}
					</view>
				</view>
			</view>
			<view class="bodys_">
				<view class="opera">
					<view v-for="(item,index) in dataList" :key="index" class="operaDet" @click="skipOpera(item.id)">
						<image :src="item.img" class="icon"></image>
						<view class="title">{{ item.text }}</view>
					</view>
				</view>
			</view>
			<view class="text">
				转账功能试行阶段,暂时不支持向支付宝银行卡用户转账
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getTransferAccounts
	} from '../../api/trade/index.js'
	import {
		getSubmit
	} from '../../api/payouts/index.js'
	import {
		getIndex
	} from '../../api/index/index.js'
	export default {
		data() {
			return {
				list: [{
						id: 0,
						text: "淘物熊",
						text2: '实时到账'
					}, {
						id: 1,
						text: "支付宝",
						text2: '即时到账'
					},
					{
						id: 2,
						text: "银行卡",
						text2: '即时到账'
					}
				],
				dataList: [{
						id: 0,
						text: '转账记录',
						img: '../../static/purse/transfer.png'
					},
					{
						id: 1,
						text: '向多人转账',
						img: '../../static/purse/transfers.png'
					}
				],
				number: '',
				money: '',
				password: '',
				type: '',
				name: '',
				handingfee: '',
				all_amount: ''
			}
		},
		onLoad() {
			this.init();
		},
		methods: {
			skipOpera(e) {
				if (e == 0) {
					uni.navigateTo({
						url: '/pages/walletDetails/wallet'
					})
				}

			},
			init() {
				getIndex().then(res => {
					this.all_amount = res.data.money;
				})
			},
			// 全部金额
			allMoney() {
				this.money = this.all_amount
			},
			// 确认转账
			btn() {
				this.$refs.pay_popup.open('center')
			},
			pay_close(e) {
				if (e == 0) {
					this.$refs.pay_popup.close('center')
				} else {
					var data = {
						money: this.money,
						tomobile: this.number,
						toname: this.name,
						pwd: this.password
					};
					this.$refs.pay_popup.close('center')
					getTransferAccounts(data).then(res => {
						uni.showToast({
							"icon": "none",
							"title": res.msg
						})
						setTimeout(() => {
							uni.navigateTo({
								url: '/pages/payouts/await'
							})
						}, 1500);
					})
				}
			},
			// 跳转
			toPath(e) {
				if (e == 0) {
					uni.navigateTo({
						url: '/pages/transfer/transfer'
					})
				} else {
					uni.showToast({
						"icon": "none",
						"title": "暂不支持向其他用户转账"
					})
				}

			}
		}
	}
</script>

<style lang="scss" scoped>
	.page {
		height: 100%;

		.bodys {
			padding: 10rpx;
			margin: 10rpx;

			.bodys_tit {
				.bodys_tit_cont {
					color: white;
					padding: 15rpx 30rpx;
					margin: 10rpx;
					font-size: 13px;
					text-align: center;
					border-radius: 15rpx;
				}

				.red {
					background-color: #ff0000;
				}

				.blue {
					background-color: #0261ff;
				}

				.ora {
					background-color: #f6591e;
				}
			}
		}

		.bodys_ {
			background-color: white;
			border-radius: 15rpx;
			margin: 30rpx 0;
			padding: 30rpx 10rpx;

			.opera {
				display: flex;
				flex-wrap: wrap;

				.operaDet {
					width: calc(100% / 6);
					border-radius: 15rpx;
					text-align: center;

					.icon {
						width: 45rpx;
						height: 45rpx;
					}

					.title {
						margin-top: 10rpx;
						font-size: 20rpx;
					}
				}
			}
		}

		.text {
			font-size: 12px;
			color: #9f9e9e;
			text-align: center;
		}
	}
</style>